<template>
  <div class="detail_container">
    <div class="head_title" v-if="!detailForm.id">创建行政处罚</div>
    <div class="head_title" v-else-if="detailForm.id && isEdit">编辑行政处罚</div>
    <div class="head_title" v-else-if="detailForm.id && !isEdit">查看行政处罚</div>
    <el-divider></el-divider>
    <div class="px-20">
      <el-form :model="params" :disabled="detailForm.id && !isEdit" ref="expertForm" class="divForm" label-width="75px" :rules="rules" label-position="left" size="small">


        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">

            <el-form-item label="处罚类型" prop="sanctionType">
              <el-select v-model="params.sanctionType" placeholder="请选择处罚类型" style="width: 100%;" >
                <el-option label="请选择字典生成" value="" />
              </el-select>
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="企业名称" prop="enterpriseName">
              <el-input v-model="params.enterpriseName" placeholder="请输入企业名称" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="信用代码" prop="creditCode">
              <el-input v-model="params.creditCode" placeholder="请输入信用代码" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">

            <el-form-item label="行政处罚类型" prop="enterpriseInfoType">
              <el-select v-model="params.enterpriseInfoType" placeholder="请选择行政处罚类型" style="width: 100%;" >
                <el-option label="请选择字典生成" value="" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="处罚日期" prop="sanctionDate">
              <el-input v-model="params.sanctionDate" placeholder="请输入处罚日期" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="监管员" prop="supervisor">
              <el-input v-model="params.supervisor" placeholder="请输入监管员" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="监管人员id" prop="supervisorId">
              <el-input v-model="params.supervisorId" placeholder="请输入监管人员id" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="处罚状态" prop="sanctionStatus">
              <el-radio-group v-model="params.sanctionStatus">
                <el-radio label="1">请选择字典生成</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="处罚内容">
              <editor v-model="params.sanctionContent" :min-height="192"/>
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="处罚图片" prop="sanctionPicture">
              <el-input v-model="params.sanctionPicture" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="处罚金额" prop="sanctionAmount">
              <el-input v-model="params.sanctionAmount" placeholder="请输入处罚金额" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="已缴纳金额" prop="paidAmount">
              <el-input v-model="params.paidAmount" placeholder="请输入已缴纳金额" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="意见编号" prop="opinionNumber">
              <el-input v-model="params.opinionNumber" placeholder="请输入意见编号" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="意见内容">
              <editor v-model="params.opinionContent" :min-height="192"/>
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="执法文书" prop="enforcementDocument">
              <el-input v-model="params.enforcementDocument" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>


          <el-col :lg="8" :xl="6">
            <el-form-item label="创建人id" prop="createId">
              <el-input v-model="params.createId" placeholder="请输入创建人id" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="更新人id" prop="updateId">
              <el-input v-model="params.updateId" placeholder="请输入更新人id" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="删除标志" prop="delFlag">
              <el-input v-model="params.delFlag" placeholder="请输入删除标志" />
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
    </div>
    <div class="flex p-20">
      <el-button @click="sureForm('expertForm')" type="primary" v-if="!detailForm.id || isEdit">确认提交</el-button>
      <el-button @click="isEdit = true" type="primary" v-if="detailForm.id && !isEdit">编辑</el-button>
      <el-button @click="show = false">返回</el-button>
    </div>
  </div>
</template>

<script>
  export default{
    data () {
      return {
        params:{
            id: null,
            sanctionType: null,
            enterpriseName: null,
            creditCode: null,
            enterpriseInfoType: null,
            sanctionDate: null,
            supervisor: null,
            supervisorId: null,
            sanctionStatus: null,
            sanctionContent: null,
            sanctionPicture: null,
            sanctionAmount: null,
            paidAmount: null,
            opinionNumber: null,
            opinionContent: null,
            enforcementDocument: null,
            createId: null,
            createBy: null,
            createTime: null,
            updateId: null,
            updateBy: null,
            updateTime: null,
            delFlag: null,
        },
        rules: {
        }
      }
    },
    props: {
      editVisible: {
        type: Boolean,
        default: () => {
          return false
        }
      },
      detailForm: {
        type: Object,
        default: () => {
          return {}
        }
      },
      isEdit:{
        type:Boolean,
        default:()=>{
          return false
        }
      },
    },
    watch:{

    },
    computed: {
      show: {
        get () {
          return this.editVisible
        },
        set (val) {
          this.$emit('update:editVisible', val)
        }
      },
    },
    created () {
      if(this.detailForm.id){
        this.params = {...this.detailForm}
      }
    },
    methods: {
      // 确认
      sureForm(formName) {
        this.$refs [formName].validate((valid) => {
          if (valid) {
            if(this.detailForm.id){
              this.$emit('submitForm', this.params,this.detailForm.id)
            }else{
              this.$emit('submitForm', this.params)
            }
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
    }

  }
</script>

<style scoped="scoped" lang="scss">
  .titile_txt{
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-weight: bold;
    font-size: 16px;
    color: #333333;
    line-height: 19px;
    margin-bottom: 15px;
  }
</style>
